home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / var / lib / dpkg / info / base-files.postinst < prev    next >
Encoding:
Text File  |  2009-04-13  |  6.0 KB  |  209 lines

  1. #!/bin/sh
  2. set -e
  3.  
  4. install_local_dir() {
  5.   if [ ! -d $1 ]; then
  6.     mkdir -p $1
  7.   fi
  8.   #chown root:staff $1 2> /dev/null || true
  9.   #chmod 2775 $1 2> /dev/null || true
  10. }
  11.  
  12. install_from_default() {
  13.   if [ ! -f $2 ]; then
  14.     cp -p $1 $2
  15.   fi
  16. }
  17.  
  18. install_directory() {
  19.   if [ ! -d /$1 ]; then
  20.     mkdir /$1
  21.     chown root:$3 /$1
  22.     chmod $2 /$1
  23.   fi
  24. }
  25.  
  26. preserve_directory() {
  27.   if [ -f /etc/base-files.create-$1 ]; then
  28.     install_directory $1 755 root
  29.     rm -f /etc/base-files.create-$1
  30.   fi
  31. }
  32.  
  33. if [ "$1" = "configure" ] && [ "$2" = "" ]; then
  34.   install_from_default /usr/share/base-files/nsswitch.conf /etc/nsswitch.conf
  35.   install_from_default /usr/share/base-files/dot.profile   /root/.profile
  36.   install_from_default /usr/share/base-files/dot.bashrc    /root/.bashrc
  37.   install_from_default /usr/share/base-files/profile       /etc/profile
  38.   install_from_default /usr/share/base-files/motd          /etc/motd
  39.   install_from_default /usr/share/base-files/networks      /etc/networks
  40.   install_directory srv       755 root
  41.   install_directory opt       755 root
  42.   install_directory etc/opt   755 root
  43.   install_directory var/opt   755 root
  44.   install_directory media     755 root
  45.   install_directory var/mail 2775 mail
  46.   if [ ! -L /var/spool/mail ]; then
  47.     ln -s ../mail /var/spool/mail
  48.   fi
  49.  
  50.   install_local_dir /usr/local
  51.   install_local_dir /usr/local/share
  52.   install_local_dir /usr/local/share/man
  53.   install_local_dir /usr/local/bin
  54.   install_local_dir /usr/local/games
  55.   install_local_dir /usr/local/lib
  56.   install_local_dir /usr/local/include
  57.   install_local_dir /usr/local/sbin
  58.   install_local_dir /usr/local/src
  59.   install_local_dir /usr/local/etc
  60.   ln -sf share/man /usr/local/man
  61.  
  62.   if [ ! -f /var/log/wtmp ]; then
  63.     echo -n>/var/log/wtmp
  64.   fi
  65.   if [ ! -f /var/log/btmp ]; then
  66.     echo -n>/var/log/btmp
  67.   fi
  68.   if [ ! -f /var/log/lastlog ]; then
  69.     echo -n>/var/log/lastlog
  70.   fi
  71.   chown root:utmp /var/log/wtmp /var/log/btmp /var/log/lastlog
  72.   chmod 664 /var/log/wtmp /var/log/btmp /var/log/lastlog
  73. fi
  74.  
  75. if [ "$1" = "configure" ] && [ "$2" != "" ]; then
  76.   if [ ! -d /var/spool/mail ] && [ ! -L /var/spool/mail ]; then
  77.     if [ -f /etc/base-files.mailsymlink ]; then
  78.       ln -sf `cat /etc/base-files.mailsymlink` /var/spool/mail
  79.     else
  80.       install_directory var/spool/mail 2775 mail
  81.     fi
  82.   fi
  83.   if [ ! -L /var/mail ] && [ ! -d /var/mail ]; then
  84.     ln -sf spool/mail /var/mail
  85.   fi
  86. fi
  87.  
  88. preserve_directory floppy
  89. preserve_directory cdrom
  90. preserve_directory initrd
  91.  
  92. if [ ! -f /var/run/utmp ]; then
  93.   echo -n>/var/run/utmp
  94. fi
  95. chown root:utmp /var/run/utmp
  96. chmod 664 /var/run/utmp
  97.  
  98. if [ ! -d /var/lib/dpkg ]; then
  99.   mkdir -m 755 -p /var/lib/dpkg
  100.   chown root:root /var/lib/dpkg
  101. fi
  102. if [ ! -f /var/lib/dpkg/status ]; then
  103.   echo > /var/lib/dpkg/status
  104.   chmod 644 /var/lib/dpkg/status
  105.   chown root:root /var/lib/dpkg/status
  106. fi
  107.  
  108. if [ ! -f /usr/info/dir ] && [ ! -f /usr/share/info/dir ]; then
  109.   install_from_default /usr/share/base-files/info.dir /usr/share/info/dir
  110.   chmod 644 /usr/share/info/dir
  111.   chown root:root /usr/share/info/dir
  112. fi
  113. rm -f /etc/base-files.mailsymlink
  114.  
  115. if [ "$1" = "configure" ] && [ "$2" != "" ]; then
  116.   newmd=`awk 'NR > 2' /usr/share/base-files/motd | md5sum | awk '{print $1}'`
  117.   if [ -f /etc/motd.tail ]; then
  118.     oldmd=`awk 'NR > 1' /etc/motd.tail | md5sum | awk '{print $1}'`
  119.     if [ "$oldmd" != "$newmd" ]; then
  120.       if grep -q "$oldmd" /usr/share/base-files/motd.md5sums; then
  121.         mv /etc/motd.tail /etc/motd.tail.old
  122.         awk 'NR > 1' /usr/share/base-files/motd > /etc/motd.tail
  123.       fi
  124.     fi
  125.   elif [ -f /etc/motd ] && [ ! -L /etc/motd ]; then
  126.     oldmd=`awk 'NR > 2' /etc/motd | md5sum | awk '{print $1}'`
  127.     if [ "$oldmd" != "$newmd" ]; then
  128.       if grep -q "$oldmd" /usr/share/base-files/motd.md5sums; then
  129.         awk 'NR <= 2' /etc/motd > /etc/motd.new
  130.         awk 'NR > 2' /usr/share/base-files/motd >> /etc/motd.new
  131.         mv /etc/motd /etc/motd.old
  132.         mv /etc/motd.new /etc/motd
  133.       fi
  134.     fi
  135.   fi
  136.  
  137.   if [ -f /etc/profile ]; then
  138.     md5=`md5sum /etc/profile | cut -f 1 -d\ `
  139.     if grep -qw "$md5" /usr/share/base-files/profile.md5sums; then
  140.         cp /usr/share/base-files/profile /etc/profile
  141.     fi
  142.   fi
  143. fi
  144.  
  145. # Ubiquity 1.9.4 thru 1.10.9 failed to set kernel permissions after
  146. # copying from the Live CD, leaving the file globally writable.
  147. if dpkg --compare-versions "$2" le-nl "4.0.4ubuntu2" &&
  148.    dpkg --compare-versions "$2" ge "4.0.1ubuntu5"
  149. then
  150.   find -L /boot -name "vmlinu[zx]-*" -perm /g+w,o+w -print0 |
  151.     xargs -0rt chmod g-w,o-w || true
  152. fi
  153.  
  154. # Ubiquity 1.7.5 thru 1.10.9 failed to restore the group id of
  155. # the process to root after doing work as the Live CD user, creating
  156. # files with that user's group as a result.
  157. if dpkg --compare-versions "$2" le-nl "4.0.4ubuntu2" &&
  158.    dpkg --compare-versions "$2" ge "4.0.1ubuntu1"
  159. then
  160.   NINER_NINER_PATHS="                \
  161.     /boot                    \
  162.     /etc                    \
  163.     /usr/lib/locale                \
  164.     /var/backups                \
  165.     /var/cache/apt                \
  166.     /var/cache/debconf            \
  167.     /var/cache/fontconfig            \
  168.     /var/cache/fonts            \
  169.     /var/cache/ldconfig            \
  170.     /var/cache/anthy            \
  171.     /var/lib/apt                \
  172.     /var/lib/dpkg                \
  173.     /var/lib/belocs                \
  174.     /var/lib/gconf                \
  175.     /var/lib/defoma                \
  176.     /var/lib/locales            \
  177.     /var/log/installer            "
  178.  
  179.   NINER_NINER_SYMLINKS="            \
  180.     /initrd.img                \
  181.     /vmlinuz                \
  182.     /cdrom                    \
  183.     /media/cdrom                \
  184.     /etc/alternatives            \
  185.     /usr/share/fonts            \
  186.     /var/lib/anthy                \
  187.     /var/lib/defoma                "
  188.  
  189.   find -L $NINER_NINER_PATHS -gid 999 -print0 |
  190.     xargs -0rt chgrp -h 0 || true
  191.   find $NINER_NINER_SYMLINKS -gid 999 -print0 |
  192.     xargs -0rt chgrp -h 0 || true
  193.   find /media -maxdepth 1 -name "cdrom[0-9]*" -gid 999 -print0 |
  194.     xargs -0rt chgrp -h 0 || true
  195. fi
  196.  
  197. if [ -f /var/lib/dpkg/info/base.list ]; then
  198.   :> /var/lib/dpkg/info/base.list
  199.   rm -f /var/lib/dpkg/info/base.conffiles
  200.   echo
  201.   echo "Note: You have the old \`base' package installed"
  202.   echo "It is very important that you do not try to remove this package"
  203.   echo "using dpkg. Please read /usr/share/doc/base-files/README.base to"
  204.   echo "get rid of the \`base' package completely in a safe way."
  205.   echo
  206.   echo -n "Press <Return> to continue "
  207.   read dummy
  208. fi
  209.